#!/bin/bash

latest=2022.2.2
latestcommit=7f9d1095ce5816185378b5f04717076e708ef05a

if [ -z "$1" ]
then
  echo -e "\033[31m未指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "$latest" ]
then
  echo -e "\033[35m开始打包指定版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.2.2" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.2.2\033[0m"
  git reset --hard 7f9d1095ce5816185378b5f04717076e708ef05a
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
elif [ "$1" == "2022.1.1" ]
then
  echo -e "\033[35m开始打包指定版本 >>> 2022.1.1\033[0m"
  git reset --hard a94308d55511482e103bb9a60eb6a2bb0b457666
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
else
  echo -e "\033[31m无指定版本\033[0m"
  echo -e "\033[35m开始打包最新版本 >>> $latest\033[0m"
  git reset --hard $latestcommit
  sleep 1
  mvn clean install
  sleep 1
  git rebase master
  echo -e "\033[36m打包完成\033[0m"
fi
